package networkinstance;

public class Main {
    public static void main(String[] args) {
        java.net.Socket skt;
        String host = "localhost";
        if (args.length > 0) {
            host = args[0];
        }
        for (int i = 0; i < 1024; i++) {
            try {
                System.out.println("查看 " + i);
                skt = new java.net.Socket(host, i);
                System.out.println("端口 " + i + " 已被使用");
            } catch (java.net.UnknownHostException e) {
                System.out.println("Exception occured" + e);
                break;
            } catch (java.io.IOException e) {
//                e.printStackTrace();
            }
        }
    }
}
